<template>
  <div>
    <van-empty description="没有搜索到相关的内容哦" v-show="!searchlist" />
    <div v-show="searchlist">
      <div
        class="recommend-list"
        v-for="item in searchlist"
        :key="item.id"
        @click="toDetail(item)"
      >
        <div class="Dtop">
          <img :src="item.avatar" alt="" />
          <div class="Dtop_left">
            <p>{{ item.name }}</p>
            <p style="color: #c0c0c0">
              <span>{{ item.position }}</span
              >&nbsp;<span>{{ item.time }}</span>
            </p>
          </div>
        </div>
        <div class="Dmain" v-show="item.type === '视频'">
          <div class="type1">
            <span class="type" style="background-color: #a0a8f8">{{ item.type }}</span>
            <span class="typebotom">{{ item.title }}</span>
          </div>
          <div class="video"></div>
          <van-text-ellipsis rows="1" :content="item.desc" />
        </div>
        <div class="Dmain" v-show="item.type === '问答'">
          <div class="type1">
            <span class="type" style="background-color: #38d1af">{{ item.type }}</span>
            <span class="typebotom">{{ item.title }}</span>
          </div>
          <van-text-ellipsis rows="1" :content="item.desc" />
        </div>
        <div class="Dmain" v-show="item.type === '音频'">
          <div class="type1">
            <span class="type" style="background-color: #7ed6ee">{{ item.type }}</span>
            <span class="typebotom">{{ item.title }}</span>
          </div>
          <div class="audio"></div>
          <van-text-ellipsis rows="1" :content="item.desc" />
        </div>
        <div class="Dmain" v-show="item.type === '文章'">
          <div class="type1">
            <span class="type" style="background-color: #43d3b4">{{ item.type }}</span>
            <span class="typebotom">{{ item.title }}</span>
          </div>
          <van-text-ellipsis rows="1" :content="item.desc" />
        </div>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
// 患者案例样式
import { onMounted, ref } from "vue";
import "./index.css";
import { useRouter } from "vue-router";
const searchlist = ref();
const router = useRouter();
const toDetail = (item) => {
  const val = encodeURIComponent(JSON.stringify(item));
  router.push(`/recdetail?item=` + val);
};

// 获取父组件传过来的参数
// const searchList = defineProps({
//   searchlist: {
//     type: Array,
//     default: () => [],
//   }})

const props = defineProps({
  searchlist: {
    type: Array,
    required: true,
  },
});

console.log(props.searchlist);


// const getlist = () => {
//   searchlist.value = searchList.searchlist;
// };
onMounted(() => {
});
</script>
